<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Areas extends Model
{
    public function getMyAreaCount()
    {
        $dealers = Dealer::where('region', $this->name)->get();
        $count = 0;
        foreach ($dealers as $dealer) {
            $count += $dealer->getAllMoneyCount();
        }
        return $count;
    }

    public function getMyGoodsCount($type)
    {
        $dealers = Dealer::where('region', $this->name)->get();
        $count = 0;
        foreach ($dealers as $dealer) {
            $count += $dealer->getOneMoneyCount($type);
        }
        return $count;
    }
}
